//
//  ValidationManageViewModel.m
//  SameWorld(merchant)
//
//  Created by 李小朋 on 2017/4/18.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "ValidationManageViewModel.h"
#import "ValidationModel.h"

@interface ValidationManageViewModel ()
@property (nonatomic ,strong) NSMutableArray *dataSource;
@end

@implementation ValidationManageViewModel

- (NSMutableArray *)dataSource {
    
    if (!_dataSource) {
        self.dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

- (void)loadValidationListNetWorking:(NSString *)bh andPage:(NSString *)page andSj:(NSString *)sj andReturnValue:(returnValueBlock)returnValue andReturenError:(returenErrorBlock)returenError {

    //  http://118.190.98.64/tctxAPI/test_secret_key_list.aspx?bh=9&page=1&sj=2017-4-1
    NSString *urlStr = [NSString stringWithFormat:@"%@/test_secret_key_list.aspx",serverUrl];
    NSDictionary *paramDic = @{@"bh":bh,@"page":page,@"sj":sj};
    [NetworkManager requestPOSTWithURLStr:urlStr paramDic:paramDic finish:^(id responseObject) {
        NSLog(@"请求成功%@",responseObject);
        NSDictionary *dict = [NSDictionary dictionaryWithDictionary:responseObject];
        NSArray *dataArray = [dict objectForKey:@"data"];
        for (NSDictionary *dic in dataArray) {
            ValidationModel *model = [[ValidationModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            [self.dataSource addObject:model];
        }
        returnValue(self.dataSource);
    } enError:^(NSError *error) {
        NSLog(@"请求失败%@",error);
        returenError(error);
    }];


}

@end
